$(function(){
	$('.showmap').on('click',function(){
		var that=this
		popup(this)
		$.ajax({
			type: 'post',
			url: '{:url("admin/beidou/cars")}',
			data: {
				number: encodeURI($(that).closest('tr').data('number'))
			},
			success: function(res) {
				console.log(res)
			}
		});
		var map = new AMap.Map('showlocation', {
			resizeEnable: true,
			zoom: 11,
			center: [118.57, 24.82]
		});
		AMapUI.loadUI(['overlay/SimpleMarker'], function(SimpleMarker) {
			console.log('创建节点')
		driverloc = new SimpleMarker({
			//普通文本
			iconStyle: {
				src: '{$static_dir}/assets/img/car.png',
				style: {
					width: '15px',
					height: '30px'
				}
			},
			position: [118.57, 24.82],
			cont: {}
		});
		console.log('放入地图')
		driverloc.setMap(map);
		});
	});
	//删除
	$('.delete-list').on('click',function(){
		console.log(1)
		popup(this,"{:url('delete')}");
		
	});
	//启用
	$('.startusing').on('click',function(){
		popup(this,"{:url('state')}");
		
	});
	//禁用
	$('.forbidden').on('click',function(){
		popup(this,"{:url('state')}");
		
	});
	//全选
	$('.check-all').on('click',function(){
		checkall(this)
	});
	$('.check-list').on('click',function(){
		checkall(this)
	});
	//删除多个
	$(".delete-multiple").on('click',function(){
		popup(this,"{:url('delete')}");
	});
	$('.unbind').on('click', function() {
		$('.driver_id').val($(this).closest('tr').data('id'))
		choosecar("{:url('car/index',['op'=>'unbind'])}?driver_id="+$(this).closest('tr').data('id'))
	});
	$('.bind').on('click', function() {
		$('.driver_id').val($(this).closest('tr').data('id'));
		var id = $(this).closest('tr').data('id');
		choosecar("{:url('car/index',['op'=>'bind'])}?driver_id="+$(this).closest('tr').data('id'));
	});
	$('.choose').on('click', function() {
		var index = parent.layer.getFrameIndex(window.name);
		parent.$('.driver').attr("value",$(this).data('name'));
		parent.$('.driver_id').attr("value",$(this).data('id'));
		parent.layer.close(index);

	});
	$('.car_rental').on('click', function() {
		choosecar("{:url('rent/index',['op'=>'search'])}")
	});
})
